 package com.farm.resume.service.impl;
 
 import com.farm.core.auth.domain.LoginUser;
 import com.farm.core.sql.query.DataQuery;
 import com.farm.core.time.TimeTool;
 import com.farm.doc.server.FarmFileManagerInter;
 import com.farm.doc.server.FarmFileManagerInter.FILE_APPLICATION_TYPE;
 import com.farm.resume.dao.ResumefilesDaoInter;
 import com.farm.resume.domain.Resumefiles;
 import com.farm.resume.service.ResumefilesServiceInter;
 import java.util.List;
 import javax.annotation.Resource;
 import org.apache.log4j.Logger;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
 
 
 
 
 
 
 
 
 
 
 
 @Service
 public class ResumefilesServiceImpl
   implements ResumefilesServiceInter
 {
   @Resource
   private ResumefilesDaoInter resumefilesDaoImpl;
   @Resource
   private FarmFileManagerInter farmFileServer;
   private static final Logger log = Logger.getLogger(ResumefilesServiceImpl.class);
   
   @Transactional
   public Resumefiles insertResumefilesEntity(Resumefiles entity, LoginUser user)
   {
     entity.setCuser(user.getId());
     entity.setCtime(TimeTool.getTimeDate14());
     entity.setCusername(user.getName());
     entity.setEuser(user.getId());
     entity.setEusername(user.getName());
     entity.setEtime(TimeTool.getTimeDate14());
     entity.setPstate("1");
     this.farmFileServer.submitFile(entity.getFileid(), 
       FarmFileManagerInter.FILE_APPLICATION_TYPE.RESUME_FILE.getValue());
     return this.resumefilesDaoImpl.insertEntity(entity);
   }
   
   @Transactional
   public Resumefiles editResumefilesEntity(Resumefiles entity, LoginUser user)
   {
     Resumefiles entity2 = this.resumefilesDaoImpl.getEntity(entity.getId());
     String oldfileid = entity2.getFileid();
     String newfileid = entity.getFileid();
     
 
 
     entity2.setFileid(entity.getFileid());
     entity2.setUserid(entity.getUserid());
     entity2.setPcontent(entity.getPcontent());
     entity2.setPstate(entity.getPstate());
     entity2.setEusername(entity.getEusername());
     entity2.setEuser(entity.getEuser());
     entity2.setCuser(entity.getCuser());
     entity2.setCusername(entity.getCusername());
     entity2.setEtime(entity.getEtime());
     entity2.setCtime(entity.getCtime());
     entity2.setId(entity.getId());
     this.resumefilesDaoImpl.editEntity(entity2);
     this.farmFileServer.updateFileState(oldfileid, newfileid, user);
     return entity2;
   }
   
   @Transactional
   public void deleteResumefilesEntity(String id, LoginUser user)
   {
     Resumefiles resumefiles = this.resumefilesDaoImpl.getEntity(id);
     this.farmFileServer.delFile(resumefiles.getFileid(), user);
     this.resumefilesDaoImpl.deleteEntity(resumefiles);
   }
   
 
   @Transactional
   public Resumefiles getResumefilesEntity(String id)
   {
     if (id == null) {
       return null;
     }
     return this.resumefilesDaoImpl.getEntity(id);
   }
   
 
   @Transactional
   public DataQuery createResumefilesSimpleQuery(DataQuery query)
   {
     DataQuery dbQuery = DataQuery.init(query, "FARM_RESUME_FILES", 
       ",FILEID,USERID,PCONTENT,PSTATE,EUSERNAME,EUSER,CUSER,CUSERNAME,ETIME,CTIME,ID");
     return dbQuery;
   }
   
   public ResumefilesDaoInter getResumefilesDaoImpl()
   {
     return this.resumefilesDaoImpl;
   }
   
   public void setResumefilesDaoImpl(ResumefilesDaoInter dao) {
     this.resumefilesDaoImpl = dao;
   }
   
   @Transactional
   public List<Resumefiles> getResumefilesListByUser(String userid)
   {
     return this.resumefilesDaoImpl.getResumefilesListByUser(userid);
   }
   
   @Transactional
   public Resumefiles getResumefilesEntity(String userid, String fileId)
   {
     return this.resumefilesDaoImpl.getResumefilesEntity(userid, fileId);
   }
   
   @Transactional
   public void deleteResumefilesWithfile(String userid, String fileId)
   {
     Resumefiles resumefiles = getResumefilesEntity(userid, fileId);
     if (resumefiles != null) {
       this.resumefilesDaoImpl.deleteEntity(resumefiles);
       this.farmFileServer.delFile(fileId, null);
     }
   }
 }
